import { Injectable } from '@nestjs/common';
import { CreateSceneTagDto } from './dto/create-scene-tag.dto';
import { UpdateSceneTagDto } from './dto/update-scene-tag.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { SceneTag } from './entities/scene-tag.entity';
import { Repository } from 'typeorm';

@Injectable()
export class SceneTagsService {
  constructor(
    @InjectRepository(SceneTag)
    private readonly sceneTagsRepository: Repository<SceneTag>,
  ) {}

  async create(createSceneTagDto: any) {
    const SceneTag = this.sceneTagsRepository.create(createSceneTagDto);
    return await this.sceneTagsRepository.save(SceneTag);
  }


  async findOne(id: string): Promise<SceneTag> {
    return this.sceneTagsRepository.findOne({ where: { id: id } });
  }

  async findAll(): Promise<SceneTag[]> {
    return this.sceneTagsRepository.find();
  }

  async findByName(name: string): Promise<SceneTag | null> {
    return this.sceneTagsRepository.findOne({ where: { name } });
  }
}
